package com.hqyj.common.dao;

import com.hqyj.common.pojo.BaseTopic;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;


/**
 * <p>
 * 基础题库 Mapper 接口
 * </p>
 *
 * @author j0701-9
 * @since 2021-10-20
 */
public interface BaseTopicMapper extends BaseMapper<BaseTopic> {

    /**
     * 随机查询 quantity 条单选题
     * @param quantity
     * @return
     */
    @Select("SELECT * FROM `base_topic` where topic_type =1 order by rand() limit #{quantity}")
    ArrayList<BaseTopic> randomSelectSingleChoice(int quantity);

    /**
     * 随机查询 quantity 条多选题
     * @param quantity
     * @return
     */
    @Select("SELECT * FROM `base_topic` where topic_type =2 order by rand() limit #{quantity}")
    ArrayList<BaseTopic> randomSelectMultipleChoice(int quantity);

    /**
     * 随机查询 quantity 条判段题
     * @param quantity
     * @return
     */
    @Select("SELECT * FROM `base_topic` where topic_type =0 order by rand() limit #{quantity}")
    ArrayList<BaseTopic> randomSelectJudge(int quantity);
}
